#include <stdio.h>
#include <stdlib.h>

void input ( int a[], int n );
int evensum ( int a[], int n );

int test2 ( int argc, char const *argv[] ) {
    int arr[30] = {0};
    int n, sum;
    printf("input array size: \n");

    scanf("%d",&n);
    if ( n < 1 || n > 30 ) return EXIT_FAILURE;
    printf("input %d numbers: \n", n);
    input(arr, n);
    sum = evensum(arr, n);
    if ( sum == -1 ) {
        printf("No even\n");
    } else {
        printf("The sum of even number is %d \n",sum);
    }
    return EXIT_SUCCESS;
}

void input ( int a[], int n ) {
    int i;
    for ( i = 0; i < n; i++ ) {
        scanf("%d",&a[i]);
    }
}

int evensum ( int a[], int n ) {
    int i, sum = 0, flag = 0;
    for ( i = 0; i < n; i++ ) {
        if ( a[i] % 2 == 0 ) {
            sum += a[i];
            flag = 1;
        }
    }
    if ( flag == 0 ) { sum = -1; }
    return sum;
}
